**************** Replication code for "THE DESIGN OF AUTOCRATIC TRADE AGREEMENTS: ECONOMIC INTEGRATION AND POLITICAL SURVIVAL" by Postnikov & Gamso ***************

//Upload dataset: Replication Dataset - Autocratic PTAs, Postnikov & Gamso

//Create Figure 1:

collapse BothAutocratic, by ( name year)
gen NotAutocraticPTA = 1 if BothAutocratic == 0
replace  NotAutocraticPTA = 0 if BothAutocratic == 1
replace NotAutocraticPTA = 1 in 334
replace BothAutocratic = 0 in 334
collapse (sum) BothAutocratic (sum) NotAutocraticPTA , by (year)
gen rsum   = sum( BothAutocratic )
twoway line BothAutocratic year, yaxis(1) || line rsum year, yaxis(2)

clear

//Upload dataset: Replication Dataset - Autocratic PTAs, Postnikov & Gamso

gen team = 1
egen a = group(team country1 country2)
egen b = group(team country2 country1)
egen c = rowmin(a b)
egen dyad = group(team c)

//Main Models (In Text)

**Table 1: Trade in services and foreign investment

vcemway probit ser_general AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, replace ctitle(Model 1)
vcemway probit ser_specific AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model 2)
vcemway probit inv_reference_general AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model 3)
vcemway probit inv_chapter AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model 4)
vcemway probit capital_movement_beyond_investme AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model 5)

** Table 2: Dispute settlement and retaliation
vcemway probit ds_prov AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, replace ctitle(Model 6)
vcemway probit ds_del_arb AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model 7)
vcemway probit ds_del_ext AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model 8)
vcemway probit ds_binding_prov AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model 9)
vcemway probit ds_sanc_prov AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model 10)

** Figure 2: Strength of DSM index

vcemway oprobit enforce AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
coefplot, drop(_cons)

** Table 3: Flexibility rises as depth and autocracy interact

vcemway poisson flexescape c.depth_index##AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, replace ctitle(Model 11)

** Figure 3: Margianl effects plot

vcemway poisson flexescape c.depth_index##AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year, robust cluster(name dyad)
margins, at(AutocraticPTAdummy=0 depth_index=(0/7))
marginsplot, name(plot0, replace)  title("Predicted flexescape with AutocraticPTAdummy = 0")
margins, at(AutocraticPTAdummy=1 depth_index=(0/4))
marginsplot, name(plot1, replace)  title("Predicted flexescape with AutocraticPTAdummy = 1") xscale(range(0 4))
graph combine plot0 plot1, ycommon

// Robustness tests (In Appendix)

// Robustness test #1: Drop China agreements 

drop if name == "Bangkok Agreement China accession" | name == "China Hong Kong" | name == "China Macao" | name == "China Pakistan" | name == "China Thailand" | name == "Association of Southeast Asian Nations (ASEAN) China" | name == "Asia Pacific Trade Agreement (Bangkok Agreement) amended" | name == "China Pakistan" | name == "Association of Southeast Asian Nations (ASEAN) China (consolidated)" | name == "China New Zealand" | name == "China Singapore" | name == "China Pakistan (consolidated)" | name == "China Peru" | name == "China Costa Rica" | name == "Asia Pacific Trade Agreement (Bangkok Agreement) amended Mongolia accession" | name == "China Switzerland" | name == "China Iceland" | name == "China Korea" | name == "China Georgia" | name == "China Maldives" | name == "China Mauritius" | name == "Regional Comprehensive Economic Partnership (RCEP)" | name == "Australia China" | name == "Bangkok Agreement China accession" | name == "Asia Pacific Trade Agreement (Bangkok Agreement) amended" | name == "Association of Southeast Asian Nations (ASEAN) China" | name == "Association of Southeast Asian Nations (ASEAN) China (consolidated)" | name == "Regional Comprehensive Economic Partnership (RCEP)" | name == "Association of Southeast Asian Nations (ASEAN) China" | name == "Association of Southeast Asian Nations (ASEAN) China (consolidated)" | name == "Regional Comprehensive Economic Partnership (RCEP)" | name == "Chile China" | name == "Chile China (consolidated)"

** Table A2: Trade in services and foreign investment
vcemway probit ser_general AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, replace ctitle(Model A1)
vcemway probit ser_specific AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A2)
vcemway probit inv_reference_general AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A3)
vcemway probit inv_chapter AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A4)
vcemway probit capital_movement_beyond_investme AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A5)

** Table A3: Dispute settlement and retaliation
vcemway probit ds_prov AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, replace ctitle(Model A6)
vcemway probit ds_del_arb AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A7)
vcemway probit ds_del_ext AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A8)
vcemway probit ds_binding_prov AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A9)
vcemway probit ds_sanc_prov AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A10)
vcemway oprobit enforce AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A11)

** Table A4: Flexibility rises as depth and autocracy interact:

vcemway poisson flexescape c.depth_index##AutocraticPTAdummy DemocraticPTAdummy GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, replace ctitle(Model A12)

clear

// Robustness test #2: Continuous regime type variable 

//Upload dataset: Replication Dataset - Autocratic PTAs, Postnikov & Gamso

gen team = 1
egen a = group(team country1 country2)
egen b = group(team country2 country1)
egen c = rowmin(a b)
egen dyad = group(team c)


** Table A5: Trade in services
vcemway probit ser_general reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, replace ctitle(Model A13)
vcemway probit ser_specific reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A14)
vcemway probit inv_reference_general reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A15)
vcemway probit inv_chapter reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A16)
vcemway probit capital_movement_beyond_investme reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A17)

** Table A6: Dispute settlement and retaliation
vcemway probit ds_prov reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, replace ctitle(Model A18)
vcemway probit ds_del_arb reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A19)
vcemway probit ds_del_ext reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A20)
vcemway probit ds_binding_prov reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A21)
vcemway probit ds_sanc_prov reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A22)
vcemway oprobit enforce reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A23)

** Table A7: Flexibility rises as depth and autocracy interact:
vcemway poisson flexescape c.depth_index##c.reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year,  robust cluster(name dyad)
outreg2 using myreg.doc, replace ctitle(Model A24)

** Table A8: Flexibility rises as depth and autocracy interact, differentiating mixed from autocratic agreements:
vcemway poisson flexescape c.depth_index##c.reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year if AutocraticPTAdummy == 1,  robust cluster(name dyad)
outreg2 using myreg.doc, replace ctitle(Model A25)
vcemway poisson flexescape c.depth_index##c.reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT year if MixedPTAdummy == 1,  robust cluster(name dyad)
outreg2 using myreg.doc, append ctitle(Model A26)

// Descriptive statistics

** Table A1: Descriptive statistics

drop if AutocraticPTAdummy  == . | DemocraticPTAdummy == . | reverse_polity == . |  GATTWTO == . |  Country1_TradeofGDP == . |  Country2_TradeofGDP == . |  Country1_FDIofGDP  == . | Country2_FDIofGDP == . |  logCountry1_GDP  == . | logCountry2_GDP == . |  logCountry1_GDPpc == . |  logCountry2_GDPpc == . |  logflow1 == . |  logflow2  == . | year == . | BIT == .

sum ser_general ser_specific inv_reference_general inv_chapter capital_movement_beyond_investme  ds_prov ds_del_arb ds_del_ext ds_binding_prov ds_sanc_prov enforce flexescape depth_index AutocraticPTAdummy DemocraticPTAdummy reverse_polity GATTWTO Country1_TradeofGDP Country2_TradeofGDP Country1_FDIofGDP Country2_FDIofGDP logCountry1_GDP logCountry2_GDP logCountry1_GDPpc logCountry2_GDPpc logflow1 logflow2 BIT
